export class LevelConfig {
    static readonly level1 = {
        id: 1,
        img: "atlas/UI/GameLevelImg/img3.jpg",
        arr: [{
            x: 1386,
            y: 1629,
            w: 234,
            h: 387,
            trueID: 0,
        }]
    }
    static readonly level2 = {
        id: 2,
        img: "atlas/UI/GameLevelImg/img4.jpg",
        arr: [{
            x: 1512,
            y: 1881,
            w: 709,
            h: 119,
            trueID: 1,
        }, {
            x: 1572,
            y: 2151,
            w: 649,
            h: 163,
            trueID: 1,
        }, {
            x: 1572,
            y: 2440,
            w: 649,
            h: 135,
            trueID: 1,
        }, {
            x: 1572,
            y: 2719,
            w: 649,
            h: 173,
            trueID: 1,
        }]
    }
    static readonly level3 = {
        id: 2,
        img: "atlas/UI/GameLevelImg/img5.jpg",
        arr: [{
            x: 893,
            y: 1261,
            w: 1273,
            h: 1053,
            trueID: 2,
        }]
    }
    static readonly level4 = {
        id: 4,
        img: "atlas/UI/GameLevelImg/img6.jpg",
        arr: [{
            x: 1075,
            y: 1613,
            w: 583,
            h: 334,
            trueID: 3,
        }, {
            x: 1795,
            y: 1652,
            w: 99,
            h: 73,
            trueID: 4,
        }]
    }


    static getLevelConfig(id: number) {
        let arr = [this.level1, this.level2, this.level3, this.level4]
        let config = arr[Math.floor(Math.random() * arr.length)]
        config.id = id;
        console.log("测试代码 测试配置", config);
        return config;
    }

    /** 关卡ID信息 */
    public static arrOflevelId: Array<number> = [];
    public static getNextLevelId(id: number) {
        console.log("关卡ID", id);

        const nextId = this.arrOflevelId.findIndex(itme => { return itme == id; })
        console.log("关卡ID Index=>", nextId);
        if (nextId != -1) {
            if (nextId + 1 < this.arrOflevelId.length) {
                return this.arrOflevelId[nextId + 1];
            }
            return -1;
        }
        return -1;
    }
}

export class LevelConfigInfo {
    /**关卡 */
    public id: number;
    /**关卡问题图片 */
    public barrierImgUrl: string;
    /**关卡提示 */
    public tips: string[];
    /**关卡问题节点数组 */
    public arrLevelQuestion: LevelQuestionInfo[];

}
export class LevelQuestionInfo {
    /**问题Id */
    public questionId: number;
    /**问题节点X */
    public questionX: number;
    /**问题节点Y */
    public questionY: number;
    /**问题节点高度 */
    public questionHeight: number;
    /**问题节点宽度 */
    public questionWidth: number;
    /**问题选项 */
    public arrQuestionOptions: string[];
    /**问题答案序号 */
    public questionAnswer: number;

    public constructor(id: number, data: any) {
        this.questionId = id;
        this.questionX = data.x;
        this.questionY = data.y;
        this.questionHeight = data.width;
        this.questionWidth = data.height;
        this.arrQuestionOptions = data.options;
        this.questionAnswer = data.barrierTipsAnswer;
    }
}